﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace SpaceMan.Particles
{
    class C_LaserBall : I_Particle
    {
        float lifeTime, scale;
        Color color;
        float decayrate;
        public C_LaserBall(Vector2 Position, Vector2 moveSpeed,Vector2 ownerSpeed ,float Scale, float DecayRate)
        {
            moveSpeed += ownerSpeed;
            this.scale = Scale;
            draw = S_Global.getDraw("GFX//TestGlow");
            color = Color.White;
            this.Position = Position;
            this.MoveSpeed = moveSpeed;
            S_Global.giveParticle(this);
            lifeTime = 400f;
            this.decayrate = DecayRate;
        }

        public override void Update()
        {

            float _decayrate = MathHelper.Clamp(decayrate + ((1 - decayrate) * (1 - S_Global.TIMESCALE)), 0, 1);
            MoveSpeed *= _decayrate;
            Position += MoveSpeed * S_Global.getTimescale() / 1000;

            lifeTime -= S_Global.getTimescale();

            color = new Color((int)255, (int)255, (int)255, (int)(255 * lifeTime / 400));

            draw.Update(Position, 0f, (int)(55 * (lifeTime / 400) * scale), (int)(55 * (lifeTime / 400) * scale), false, color);
            

            if (lifeTime <= 0)
            {
                MarkedForDeletion = true;
            }
        }
    }
}
